<?php


namespace app\admin\model;


use think\facade\Cache;
use think\Model;

class UserChangeType extends Model
{
    public static function getTitleById($type = 'all')
    {
        $arr = Cache::get('change_type_id2title') ?? self::where('status', 1)->column('title', 'id');
        if ($type == 'all') {
            return $arr;
        } else {
            return $arr[$type];
        }
    }

    public static function getTitleByName($name = 'all')
    {
        $arr = Cache::get('change_type_name2title') ?? self::where('status', 1)->column('title', 'name');
        if ($name == 'all') {
            return $arr;
        } else {
            return $arr[$name];
        }
    }

    public static function getIdByName($name = 'all')
    {
        $arr = Cache::get('change_type_name2id') ?? self::where('status', 1)->column('id', 'name');
        if ($name == 'all') {
            return $arr;
        } else {
            return $arr[$name];
        }
    }


}